package engine

import (
	"log"
)

type SimpleEngine struct {}

func (e SimpleEngine) Run(seeds ...Request) {
	var requests []Request

	//种子加入requests
	for _,r:= range seeds{
		requests = append(requests, r)
	}

	for len(requests)>0{
		r := requests[0]
		requests = requests[1:]

		parserResult, err := Worker(r)
		if err != nil {
			continue
		}
		//将解析出来的多个结果，放入requests，然后一个个遍历出来
		requests = append(requests, parserResult.Requests...)

		for _,item:= range parserResult.Items{
			log.Printf("Got item %v", item)
		}
	}
}
